﻿//
// GNS_HallScene.h
// MobileManageSys
//FuncTion 主页面场景
// Created by mr.l on 16/1/12.
//
//

#ifndef __MobileManageSys__GNS_HallScene__
#define __MobileManageSys__GNS_HallScene__

#include "cocos2d.h"
#include "cocostudio/CocoStudio.h"
#include "ui/CocosGUI.h"
#include "GNS_PopWndUserInfo.h"
#include "GNS_PopWndPassWord.h"
#include "GNS_ApplyTopUp.h"
#include "GNS_ApplyTick.h"
#include "GNS_PlayerCritValue.h"
#include "GNS_PlayerTopPro.h"
#include "GNS_PromoterPro.h"
#include "GNS_UserTopUp.h"
#include "GNS_GameDown.h"
#include "GNS_ManageRecord.h"
#include "GNS_TopAndTick.h"
#include "GNS_Accounted.h"
#include "GNS_NewPromoter.h"
#include "GNS_PlayerDate.h"
#include "GNS_PvpApplyTick.h"
#include "GNS_PvEAllDate.h"
#include "GNS_PvEAllInfo.h"
#include "GNS_DailyTop.h"
#include "GNS_DailyTick.h"
#include "GNS_DailyTransfer.h"
#include "GNS_MakeLayer.h"
#include "GNS_Handler.h"
USING_NS_CC;
using namespace cocostudio::timeline;
using namespace ui;
US_NS_CUSTOM_UI;

enum{
    SYSTEM                                                          =1,//管理系统
    PROMOTERS                                                  =2,//推广人员
    PLAYER                                                           =3,//直属玩家
    REVENUEReport                                              =4, //营收报告
    /////////////////////////////管理系统////////////////////////////////////////////////
    SYSTEM_USERINFOR                                    =100,//个人信息
    SYSTEM_PASSWORLD                                  =101,//密码修改
    SYSTEM_APPLYTOU                                     =102,//申请充值
    SYSTEM_APPLYTICKET                                  =103,//申请兑奖
    SYSTEM_PLAYERTOPRO                               =104,//玩家充值比例
    SYSTEM_PROMOTERTOPRO                        =105,//推广员充值比例
    SYSTEM_PLAYERCRITVALUE                         =106,//直属玩家暴击值
    SYSTEM_USERTOP                                       =107,//个人充值/兑奖/转账查询
    SYSTEM_GAMEDOWN                                 =108,//游戏下载
    SYSTEM_MANAGEREC                                 =109, //管理记录
    SYSTEM_CALLBACK                                      =110,//返回登录
    ////////////////////////////推广人员///////////////////////////////////////////////////
    PROMOTER_TOPANDTICK                           =201,//充值兑奖
    PROMOTER_ACC                                          =202,//占比
    PROMOTER_NEW                                         =203, //新增推广员
    ////////////////////////////直属玩家///////////////////////////////////////////////////
    PLAYER_DATE                                               =300,
    ////////////////////////////营收报告///////////////////////////////////////////////////
    REVREP_PVP                                                 =400,//人人对战收税分成
    REVREP_PVE                                                 =401,//人机对战总玩数据
    REVREP_PVE_INTO                                        =402,//人机对战总玩分成
    REVREP_TOP                                                 =403,//每日充值
    REVREP_TICK                                                =404,//每日兑奖
    REVREP_TRANSFER                                       =405 //每日转账
};
class GNS_HallScene : public Layer
{
public:
    GNS_HallScene();
    ~GNS_HallScene();
    static Scene * createScene();
    virtual bool init();
    CREATE_FUNC(GNS_HallScene);

    void BtnCallBack(Ref *pSender , ui::Widget::TouchEventType type);//选项卡回调事件
    void SysteBtnCallBack(Ref *pSender,ui::Widget::TouchEventType type);//管理系统回调事件
    void PromoterBtnCallBack(Ref*pSender,ui::Widget::TouchEventType type);//推广人员/运营商回调事件
    void PlayerBtnCallBack(Ref*pSender,ui::Widget::TouchEventType type);//直属玩家回调事件
    void ReveBtnCallBack(Ref *pSender,ui::Widget::TouchEventType type);//营收报告回调事件
    void SelectedItemEvents(Ref*pSender,ui::Widget::TouchEventType type);//直属玩家 ListView item 事件
    void CallBackLogin(Ref*pSender,ui::Widget::TouchEventType type);
    void NodeChoose(Node * pNode);//选项卡 Node 切换已经 子 Node 释放
    void PlayerDate();//直属玩家数据
    /*PopWndLayer * OnUIAction(std::string Text,bool Effect);*/

    bool OnHandleSocketMsg(const int &mainCmd, const int &subCmd, const void *msgData, const int &dataLen);
    PopWndLayer * OnUIAction2(std::string Text,bool isUTF);
	int reConnectResult(int iClientId, int iSubCode, int iReconnectCount);
	void closeConnectCallBack(cocos2d::Ref *pSender, ui::Widget::TouchEventType type);

public:
	// 进入场景后，要初始化内容
	virtual void onEnterTransitionDidFinish();

	// 离开场景前，要释放内容
	virtual void onExitTransitionDidStart();

	// 事件桥定时器的回调函数
	void onEventBridge(float dt);
public:
    Button * SysteManage;//管理系统
    Button * Promoters;//推广人员
    Button * Player;//直属玩家
    Button * RevenueReport;//营收报告
public:
    void AddUserInfo(CMD_SC_GetMobileUserinfoResult*pDate);
    PopWndLayer * pPopWnd=nullptr;
    void updateRefresh(bool bFlag);
	void RefreshManage(float dt);
private:
    void initData();
    void ObtainRef();//加载 HallSceneUI 数据
    void ObtainPromter();//加载 推广员/运营商 UI 数据
    void ObtainPlayer();//加载 直属玩家UI 数据
    void ObtainRevRep();//加载 营收报告UI 数据
    void SetButtonState();//设置选项卡 按钮状态
    void PlayerShowDate(int type = 0);//直属玩家数据显示
	void addMakerLayer();
	void playerSearchFunc();
	void popSearchTips();
	void searchSingleListView();
	void refreshList(CMD_SC_GetLowlineUserInfoResult it, int x);
	void setSwallowsTouches(bool swallowsTouches);

	bool flag = false;
private:
    Node * rootNode;//HallScene 相对应的 Node
    Node * SystemLayer;//管理系统 相对应的 Node
    Node * PlayerLayer;//直属玩家 相对应的 Node
    Node * RevenuReport; //营收报告 相对应的 Node
    Node * Promoter;//推广人员 相对应的 Node
    Vector<Node *>_NodeVec; //HallScene选项卡 Node的Vector
    Node * NullNode;//切换 Node 恒定为 Null
    TextField * IDTextField;
    ListView * pTypeList;
    Text * Exchtext;
    Sprite * pSptbg;
    bool IsShowPlayBg;
    int Mon;
    int year;
    int day;
    ImageView * Exclamation;
    ListView * pListView;
    vector<CMD_SC_GetLowlineUserInfoResult>_LowlineInfo;
    int UersType;//玩家等级
    int NumPlayer=0;
    ImageView * Titbgplayer=nullptr;
    Text * Text_9=nullptr;
    Text * Text_9_0=nullptr;
    bool OperatorAgent=false;

	GNS_MakeLayer * pInfoMakeLayer;

	CustomEditBox * _IDTextField;

	vector<CMD_SC_GetLowlineUserInfoResult> tempSearchVector;
public:
    /**
     * SystemManage包含的层
     */
    GNS_PopWndUserInfo * pUserInfo;
    GNS_PopWndPassWord * PassWordLayer;
    GNS_ApplyTopUp * pApplyTopUp;
    GNS_ApplyTick * pApplyTick;
    GNS_PlayerTopPro * pPlayerTopPro;
    GNS_PromoterPro * pPromoterPro;
    GNS_PlayerCritValue * pPlayerCritValue;
    GNS_UserTopUp * pUserTopUpLayer;
    GNS_GameDown * pGameDow;
    GNS_ManageRecord * pManageRec;
    /**
     *  Promoter 包含的层
     */
    GNS_TopAndTick * pTopAndTick;
    GNS_Accounted * pAccounter;
    GNS_NewPromoter * pNewPromoter;
    /**
     *  Player 包含的层
     */
    GNS_PlayerDate * pPlayerDate;
    /**
     *  RevenuReport 包含的层
     */
    GNS_PvpApplyTick * pPvpApplyTick;
    GNS_PvEAllDate * pPvEAllDate;
    GNS_PvEAllInfo * pPvEAllInfo;
    GNS_DailyTop * pDailyTop;
    GNS_DailyTick * pDailyTick;
    GNS_DailyTransfer * pDailyTransfer;

};

#endif /* defined(__MobileManageSys__GNS_HallScene__) */